/*
 * Copyright Hundsun Technologies Inc. All Rights Reserved.
 */

package main

import (
	"fmt"
	"os"

	"github.com/spf13/cobra"
	"hundsun.com/hsl/hschain/cmd/cli/common"
	"hundsun.com/hsl/hschain/cmd/cli/dapp"
	"hundsun.com/hsl/hschain/cmd/cli/dapp/genesisblock"
	"hundsun.com/hsl/hschain/cmd/cli/dapp/tx"
	"hundsun.com/hsl/hschain/common/version"
	_ "hundsun.com/hsl/hschain/contract/init"
	"hundsun.com/hsl/hschain/contractmanager"
)

func main() {

	mainCmd := &cobra.Command{
		Use:     common.ClientCmdName,
		Short:   common.ClientCmdDesc,
		Long:    common.ClientCmdDesc,
		Version: version.GetVersion(),
	}

	mainFlags := mainCmd.PersistentFlags()
	mainFlags.String(common.FlagRPCLaddr, "127.0.0.1:50001", "rpc address")
	mainFlags.String(common.FlagChainID, "main", "chain id")
	mainCmd.AddCommand(
		tx.Cmd(),

		dapp.NetCmd(),
		dapp.BlockCmd(),
		dapp.AccountCmd(),
		genesisblock.Cmd(),
		dapp.TxPoolCmd(),
		dapp.ConsensusCmd(),
	)
	contractmanager.AddCmd(mainCmd)
	if err := mainCmd.Execute(); err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
}
